﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WordGame.Question;
using System.Collections;

namespace WordGame.Answer
{
    class Jimson:IWordGame
    {

        public int getCheater(string[] first, string[] second, string[] third)
        {
            List<string> arr = new List<string>();


            for (int i = 0; i < 50; i++)
            {
                if (first.Length > i)
                {
                    arr.Add(first[i]);
                }
                else
                {
                    break;
                }
                if (second.Length > i)
                {
                    arr.Add(second[i]);
                }
                else
                {
                    break;
                }
                if (third.Length > i)
                {
                    arr.Add(third[i]);
                }
                else
                {
                    break;
                }
            }

            int Num = 0;
            string currentWord = first[0];
            for (int i = 1; i < arr.Count; i++)
            {
                if (arr[i].Substring(0, arr[i].Length - 1) == currentWord || arr[i].Substring(1, arr[i].Length - 1) == currentWord)
                {
                    currentWord = arr[i];
                    Num = i;
                }
                else
                {
                    break;
                }
               
                
               
            }

            if (Num == arr.Count - 1)
            {
                return -1;
            }
            else
            {
                return Num % 3 +1;
            }
        }
    }
}
